#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
struct Work {
  int t, f;
} w[200005];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> w[i].t >> w[i].f;
  }
  sort(w + 1, w + n + 1, [](Work a, Work b) { return a.t * b.f < b.t * a.f; });
  LL ans = 0;
  LL now = 0;
  for (int i = 1; i <= n; i++) {
    now += w[i].t;
    ans += now * w[i].f;
  }
  cout << ans << endl;
  return 0;
}
